import { BadRequestException, ValidationPipe } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { exception } from 'node:console';
import { AppModule } from './app.module';
import { errorReturn } from './utils';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);

  app.useGlobalPipes(new ValidationPipe({transform : true, exceptionFactory : (err) => {
    let msg = err[0].constraints.isNotEmpty
    return new BadRequestException(errorReturn(msg));
  }}));

  await app.listen(3000);
}
bootstrap();
